﻿@namespace CodeManDesktopBlazor.BlazorComponents.Pages

<Router AppAssembly="@typeof(MainWindow).Assembly">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
    </Found>
    <NotFound>
        <LayoutView Layout="@typeof(MainLayout)">
            <p>Sorry, there's nothing at this address.</p>
        </LayoutView>
    </NotFound>
</Router>
@code {
    /// <summary>
    ///
    /// </summary>
    [Inject]
    private IJSRuntime JSRuntime { get; set; }

    /// <summary>
    ///
    /// </summary>
    /// <param name="firstRender"></param>
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        await base.OnAfterRenderAsync(firstRender);

        @*&& OperatingSystem.IsBrowser()*@

        if (firstRender)
        {
            try
            {
                await Task.Delay(100);
                await JSRuntime.InvokeVoidAsync("$.loading");
            }
            catch (Exception ex)
            {
                await Task.Delay(1000);
                await JSRuntime.InvokeVoidAsync("$.loading");
            }
        }
    }
}
